namespace GNSystem.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using GNSystem.Models;

    internal sealed class Configuration : DbMigrationsConfiguration<GNSystem.Models.DataContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
            
        }

        protected override void Seed(GNSystem.Models.DataContext context)
        {
            if (context.UserGroups.Count() > 0)
                return;
            var regular = new Group()
            {
                GroupName = "Regular Users",
                GroupAdjective = "Regular User",
                AllowedViewing = true,
                AllowedPosting = true,
                AllowedCommenting = true,
                NameStyle = "",
            };
            var banned = new Group()
            {
                GroupName = "Banned Users",
                GroupAdjective = "Banned",
                AllowedViewing = false,
                AllowedPosting = false,
                AllowedCommenting = false,
                NameStyle = "text-decoration: line-through; color: gray;",
            };
            var moderator = new Group()
            {
                GroupName = "Moderators",
                GroupAdjective = "Moderator",
                AllowedViewing = true,
                AllowedPosting = true,
                AllowedCommenting = true,
                IsStaff = true,
                NameStyle = "text-decoration: underline; color: green; font-weight: 600;",
            };
            var admin = new Group()
            {
                GroupName = "Administrators",
                GroupAdjective = "Admin",
                AllowedViewing = true,
                AllowedPosting = true,
                AllowedCommenting = true,
                IsStaff = true,
                IsAdmin = true,
                NameStyle = "text-decoration: underline; color: red; font-weight: 800;",
            };
            context.UserGroups.AddOrUpdate(
                regular,
                banned,
                moderator,
                admin
                );
        }
    }
}
